package org.UserHouse.Servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.UserHouse.Dao.Imp.UserDaoImp;
import org.UserHouse.Dao.UserDao;
import org.UserHouse.entity.User;

import java.io.IOException;
import java.io.PrintWriter;

/**
 * @author bin
 * @date 2024-11-28
 */
@WebServlet("/reg.do")
public class regServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setContentType("text/html;charset=UTF-8");
        PrintWriter out = resp.getWriter();

        String Uname = req.getParameter("Uname");
        String Upassword = req.getParameter("Upassword");
        String Uphone = req.getParameter("Uphone");
        String Uemail = req.getParameter("Uemail");

        int n;
        UserDao userDao = new UserDaoImp();
        User user = new User();
        user.setUname(Uname);
        user.setUpassword(Upassword);
        user.setUphone(Uphone);
        user.setUemail(Uemail);
        n = userDao.insertUser(user);

        out.println(n);

        out.flush();
        out.close();
    }
}
